
import { Button, Card, Input } from "element-react";
import React, { useCallback, useState } from "react";
import http from "src/utils/http";

const api = '/api/v1/system/settings/menuConfiguration'

const Test: React.FC = () => {
  const [response, setResponse] = useState<string>();
  const handleInvoke = useCallback(async () => {
    try {
      const resp = await http.get(api);
      setResponse(JSON.stringify(resp));
    } catch (error) {
      setResponse(JSON.stringify(error));
    }
  }, []);
  const handleReset = useCallback(() => {
    setResponse(undefined);
  }, []);

  return (
    <Card
      className="box-card"
      header={
        <div className="clearfix">
          <span style={{ "lineHeight": "36px" }}>API: {api}</span>
          <span style={{ "float": "right" }}>
            <Button type="primary" onClick={handleInvoke}>测试</Button>
            <Button type="primary" onClick={handleReset}>重置</Button>
          </span>
        </div>
      }
    >
      <Input type="textarea" value={response} rows={10}></Input>
    </Card>
  );
};

export default Test;
